package org.example.tree;

/**
 * @ClassName 矩形类，用于表示区域或阻挡物的边界
 * @Description TODO
 * @Author hongjun
 * @Date 2024/5/17 下午10:30
 * @Version 1.0
 */
//
class Rectangle {
    int x, y, width, height;

    public Rectangle(int x, int y, int width, int height) {
        super();
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    // 判断两个矩形是否相交
    public boolean intersects(Rectangle other) {
        return this.x < other.x + other.width &&
                this.x + this.width > other.x &&
                this.y < other.y + other.height &&
                this.y + this.height > other.y;
    }

    public boolean contains(int x, int y) {
        return x >= this.x && x < this.x + this.width && y >= this.y && y < this.y + this.height;
    }
    // 省略getter和setter等方法...
}

